package binary

import (
	"bytes"

	"github.com/gogf/gf/os/gfile"
)

var Binary map[string]*bytes.Buffer
var Jsons map[string]map[string]interface{}

// func Init(workDir string, ch chan bool, fileCount *int) {
func Init(workDir string) (ch chan bool, fileCount int) {
	ch = make(chan bool)
	Binary = make(map[string]*bytes.Buffer)
	Jsons = make(map[string]map[string]interface{})
	// fileCount := 0

	// initFunc:=make([]func(), 10)

	var initFunces []func(string, chan bool) = []func(string, chan bool){containerHtml, headerHtml, wsHtml, footerHtml, layoutHtml, containerHtml, testJson, fishdb_kePy, fishdb_shuPy, fundiving_kePy, fundiving_shuPy, keJson}
	// go fundiving_shuPy(workDir)
	// *fileCount = len(initFunces)

	for _, initFunc := range initFunces {
		// make([]byte, 1)
		go initFunc(workDir, ch)
	}

	return ch, len(initFunces)
}

func writeBinaryFile(workDir, dir, fileName string) {
	gfile.PutBytes(workDir+dir+fileName, Binary[fileName].Bytes())
}
